package com.meizi.core.tool.api;

import java.util.List;

/**
 * @author meizi
 * @email enjoymeizi@gmail.com
 * @date 2020/11/27 14:12
 */
public class PageResult<T> {
    private List<T> rows;
    private Long total;

    public static <T> PageResult of(List<T> rows, Long total) {
        return new PageResult(rows, total);
    }

    public List<T> getRows() {
        return this.rows;
    }

    public Long getTotal() {
        return this.total;
    }

    public void setRows(final List<T> rows) {
        this.rows = rows;
    }

    public void setTotal(final Long total) {
        this.total = total;
    }

    @Override
    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof PageResult)) {
            return false;
        } else {
            PageResult<?> other = (PageResult)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                Object this$rows = this.getRows();
                Object other$rows = other.getRows();
                if (this$rows == null) {
                    if (other$rows != null) {
                        return false;
                    }
                } else if (!this$rows.equals(other$rows)) {
                    return false;
                }

                Object this$total = this.getTotal();
                Object other$total = other.getTotal();
                if (this$total == null) {
                    if (other$total != null) {
                        return false;
                    }
                } else if (!this$total.equals(other$total)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof PageResult;
    }


    @Override
    public String toString() {
        return "PageResult(rows=" + this.getRows() + ", total=" + this.getTotal() + ")";
    }

    public PageResult() {
    }

    public PageResult(final List<T> rows, final Long total) {
        this.rows = rows;
        this.total = total;
    }
}
